/*
 * @description:
 * @version: 1.0.1
 * @Author: xuqiulin
 * @Date: 2021-04-30 11:08:49
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-04-30 21:21:32
 */
package cmd

import (
	"GameServer/ServerWeb/routers"
	"fmt"
	"net/http"
	"time"

	_ "net/http/pprof"
)

func Run(port string) {
	r := routers.Router()
	s := &http.Server{
		Addr:           ":" + port,
		Handler:        r,
		ReadTimeout:    120 * time.Second,
		WriteTimeout:   120 * time.Second,
		MaxHeaderBytes: 1 << 20,
	}
	s.ListenAndServe()
}

func RunPProf(port string) {
	// 开启pprof，监听请求
	ip := "0.0.0.0:" + port
	if err := http.ListenAndServe(ip, nil); err != nil {
		fmt.Printf("start pprof failed on %s\n", ip)
	}
}
